package com.xxl.job.executor.util;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.text.SimpleDateFormat;

public class JsonUtil {

    /**
     * 获取kafka对象
     * @return
     */
    public static ObjectMapper getObjectMapper(){
        ObjectMapper ob = new ObjectMapper();
        //json转bean时忽略大小写
        ob.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
        //如果json中有新增的字段并且是实体类类中不存在的，不报错
        ob.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        // 修改时间格式
        ob.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"));

        return ob;
    }

}
